package com.pxst.internalReports.controller;

import com.pxst.fi.service.SysBankBillService;
import com.pxst.internalReports.req.VirtualBankStatementReq;
import com.pxst.internalReports.req.VirtualBankStatementSearchReq;
import com.pxst.internalReports.req.VirtualBankStatementUpdateReq;
import com.pxst.resp.ApiResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @author Chrissy
 * @since 2023-11-01 10:55:00
 */
@Api(tags = "虚拟银行对账单相关接口")
@RestController
@RequestMapping("/Internal/VirtualBankStatement")
@Validated
public class VirtualBankStatementController {

    @Autowired
    private SysBankBillService sysBankBillService;

    /**
     * 虚拟银行对账单搜索接口
     *
     * @param searchReq 接收前端发送的搜索条件数据
     * @return
     */
    @ApiOperation(value = "虚拟银行对账单搜索接口")
    @GetMapping("/searchVirtualBankStatement")
    public ApiResp searchVirtualBankStatement(VirtualBankStatementSearchReq searchReq) {
        return ApiResp.sucess(sysBankBillService.searchVirtualBankStatement(searchReq));
    }

    /**
     * 虚拟银行对账单汇出报表接口
     *
     * @param searchReq 接收前端发送的搜索条件数据
     * @return
     */
    @ApiOperation(value = "虚拟银行对账单汇出报表接口")
    @GetMapping("/downloadVirtualBankStatement")
    public void downloadVirtualBankStatement(VirtualBankStatementSearchReq searchReq, HttpServletResponse response) {
        sysBankBillService.downloadVirtualBankStatement(searchReq, response);
    }

    /**
     * 虚拟银行对账单范本接口
     *
     * @return
     */
    @ApiOperation(value = "虚拟银行对账单范本接口")
    @GetMapping("/downloadVBSUploadExample")
    public void downloadVBSUploadExample(HttpServletResponse response) {
        sysBankBillService.downloadVBSUploadExample(response);
    }

    /**
     * 虚拟银行对账单新增接口
     *
     * @return
     */
    @ApiOperation(value = "虚拟银行对账单新增接口")
    @PostMapping("/createVirtualBankStatement")
    public ApiResp createVirtualBankStatement(@RequestBody @Valid VirtualBankStatementReq bankStatementReq) {
        return sysBankBillService.createVirtualBankStatement(bankStatementReq);
    }

    /**
     * 虚拟银行对账单对账修改接口
     *
     * @return
     */
    @ApiOperation(value = "虚拟银行对账单对账修改接口")
    @PostMapping("/updateVirtualBankStatement")
    public ApiResp updateVirtualBankStatement(VirtualBankStatementUpdateReq req) {
        return sysBankBillService.updateVirtualBankStatement(req);
    }

    /**
     * 虚拟银行对账单对账上传新增接口
     * @return
     */
    @ApiOperation(value = "虚拟银行对账单对账上传新增接口")
    @PostMapping("/uploadVirtualBankStatement")
    public ApiResp uploadVirtualBankStatement(@RequestParam(value = "file") MultipartFile file, HttpServletRequest request) throws Exception {
        return sysBankBillService.uploadVirtualBankStatement(file, request);
    }

}
